# Q:The population count of a bitstring is the number of set bits (1-bits) in
# the string. For instance, the population count of the number 23, which is
# represented in binary as 101112, is 4. The population count is used in
# cryptography and error-correcting codes, among other topics in computer
# science; some people use it as an interview question. The population count is
# also known as Hamming weight.
#
# A:We just use the bitwise check and shift the bit to the right repeatedly
# until the number becomes 0

def population_count(num):
   count = 0
   while num:
      count += num & 1
      num >>= 1
   return count
